package com.fc.mall.service.impl;

import com.fc.mall.dao.SmsBargainPromotionProductDao;
import com.fc.mall.dto.SmsBargainPromotionProduct;
import com.fc.mall.service.SmsBargainPromotionProductService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * User: Charles.Gao
 * Date: 2019-09-07 16:06
 */
@Service
public class SmsBargainPromotionProductServiceImpl implements SmsBargainPromotionProductService {
    @Autowired
    SmsBargainPromotionProductDao bargainPromotionProductDao;

    @Override
    public int create(SmsBargainPromotionProduct bargainPromotion) {
        return bargainPromotionProductDao.insert(bargainPromotion);
    }

    @Override
    public int delete(Long id) {
        return bargainPromotionProductDao.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Long id, SmsBargainPromotionProduct bargainPromotion) {
        return bargainPromotionProductDao.updateByPrimaryKey(bargainPromotion);
    }

    @Override
    public List<SmsBargainPromotionProduct> list(Long promotionId, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        return bargainPromotionProductDao.getListByPromotionId(promotionId);
    }

    @Override
    public SmsBargainPromotionProduct getBargainPromotionProduct(Long id) {
        return bargainPromotionProductDao.getByPrimaryKey(id);
    }
}
